package com.face.server.service.impl;

import com.face.RespMsg;
import com.face.server.dao.ApplyDao;
import com.face.server.entity.Apply;
import com.face.server.entity.Student;
import com.face.server.repository.ApplyRepository;
import com.face.server.service.ApplyService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.PageImpl;
import org.springframework.data.domain.Pageable;
import org.springframework.data.mongodb.core.query.Criteria;
import org.springframework.data.mongodb.core.query.Query;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.Date;
import java.util.List;

import static org.springframework.data.mongodb.core.query.Criteria.where;

/**
 * Created by ryan on 2018/3/27.
 */
@Service
public class ApplyServiceImpl implements ApplyService {

    @Autowired
    private ApplyRepository applyRepository;

    @Autowired
    private ApplyDao applyDao;

    @Override
    public RespMsg list(Pageable pageable, Date begin, Date end, String input) {
        List<Apply> applyList=applyDao.list(pageable,begin,end,input);
        return RespMsg.build(new PageImpl<Apply>(applyList,pageable,applyList.size()));
    }

    @Override
    public RespMsg listMy(Pageable pageable, Date begin, Date end, String input, List<Integer> dormitoryNumList) {
        List<Apply> applyList=applyDao.listMy(pageable,begin,end,input,dormitoryNumList);
        return RespMsg.build(new PageImpl<Apply>(applyList,pageable,applyList.size()));
    }


}
